 

package com.hs.core.utils;

import org.apache.commons.lang.StringUtils;
 
public class OrderTool {
	
	
	/** 
	 * @param basePath
	 * @param orderValueStr
	 * @return
	 */
	public static String getOrderImage(String basePath, String orderValueStr) {
		if(StringUtils.isBlank(orderValueStr))
			orderValueStr = "1";
		int orderValue = Integer.parseInt(orderValueStr); 
		StringBuffer buffer = new StringBuffer("<img src=\"");
		buffer.append(basePath);
		buffer.append("index/Themes/com/");
		if (orderValue == 0)
			return "";
		if (orderValue == 1){
			 buffer.append("down.gif\"").append(" border=0 />");
			return  buffer.toString();
		}
		if (orderValue == 2){
			 buffer.append("up.gif\"").append(" border=0 />");
			 return  buffer.toString();
		}
		return "";
	}
    public static String getOrderNum(String fieldName,String orderName,String orderNum){ 
    	if(!fieldName.equals(orderName))
    		return "1";
    	else{
    	if("1".equals(orderNum))
    		return "2";
    	if("2".equals(orderNum))
    		return "1";
    	}
    	return "1";
    }
    public static String getOrderNum(String fieldName,String orderName,String orderNum,String flag){
    	 String returnVal = "1";
    	if(!fieldName.equals(orderName))
    		return "1";
    	else{
	    	if("1".equals(orderNum)&&StringUtils.isNotBlank(flag))
	    		returnVal = "2"; 
	    	if("2".equals(orderNum)&&StringUtils.isNotBlank(flag)){
	    		returnVal = "1";
	    	} 
    	}
    	return returnVal;
    }
	 

}
